﻿// Decompiled with JetBrains decompiler
// Type: Netick.CodeGen.PostProcessorReflectionImporter
// Assembly: Netick.CodeGen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 95965C71-875F-44B8-BA79-93A19C7D6A17
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Editor\Netick.CodeGen.dll

using Mono.Cecil;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

#nullable disable
namespace Netick.CodeGen;

internal class PostProcessorReflectionImporter : DefaultReflectionImporter
{
  private const string k_SystemPrivateCoreLib = "System.Private.CoreLib";
  private readonly AssemblyNameReference m_CorrectCorlib;

  public PostProcessorReflectionImporter(ModuleDefinition module)
    : base(module)
  {
    this.m_CorrectCorlib = ((IEnumerable<AssemblyNameReference>) module.AssemblyReferences).FirstOrDefault<AssemblyNameReference>((Func<AssemblyNameReference, bool>) (a => a.Name == "mscorlib" || a.Name == "netstandard" || a.Name == "System.Private.CoreLib"));
  }

  public virtual AssemblyNameReference ImportReference(AssemblyName reference)
  {
    return this.m_CorrectCorlib == null || !(reference.Name == "System.Private.CoreLib") ? base.ImportReference(reference) : this.m_CorrectCorlib;
  }
}
